package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.Category;
import edu.scau.mis.pos.mapper.CategoryMapper;
import edu.scau.mis.pos.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 林琛理
 * @date 2022/9/13 12:53
 */
@Service
public class CategoryServiceImpl implements ICategoryService {
    @Resource
    private CategoryMapper categoryMapper;

    @Override
    public Category getCategoryById(Long categoryId) {
        return categoryMapper.getCategoryById(categoryId);
    }

    /**
     * 列出所有类别
     * @return
     */
    @Override
    public List<Category> listAllCategory() {
        return categoryMapper.listAllCategory();
    }

    @Override
    public Category selectCategoryById(Long cateogryId) {
        return categoryMapper.selectCategoryById(cateogryId);
    }

    @Override
    public List<Category> selectCategoryList(Category category) {
        return categoryMapper.selectCategoryList(category);
    }

    @Override
    public int insertCategory(Category cateogry) {
        cateogry.setCreateTime(new Date());
        return categoryMapper.insertCategory(cateogry);
    }

    @Override
    public int updateCategory(Category cateogry) {
        cateogry.setUpdateTime(new Date());
        return categoryMapper.updateCategory(cateogry);
    }

    @Override
    public int deleteCategoryById(Long cateogryId) {
        return categoryMapper.deleteCategoryById(cateogryId);
    }


}
